package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniu.entity.Result;
import com.woniu.pojo.DetailedOrder;
import com.woniu.mapper.DetailedOrderMapper;
import com.woniu.service.IDetailedOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.vo.GoodsOrderVo;
import com.woniu.vo.OrderDetailOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author QiuPeng
 * @since 2022-10-12
 */
@Service
public class DetailedOrderServiceImpl extends ServiceImpl<DetailedOrderMapper, DetailedOrder> implements IDetailedOrderService {
        @Autowired
        private  DetailedOrderMapper detailedOrderMapper;

    /**
     *  通过订单id删除订单详细信息
     * @param orderId
     */
    @Override
    public void removeDetailOrder(String orderId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("order_id",orderId);
        detailedOrderMapper.delete(queryWrapper);


    }

    /**
     * 查询订单详细信息 和商品详细信息
     * @param orderId
     * @return
     */
    @Override
    public OrderDetailOrderVo searchByOrderId(String orderId) {




        OrderDetailOrderVo orderDetailOrderVo = detailedOrderMapper.selectByOrderId(orderId);

        List<GoodsOrderVo> goodsOrderVoList = detailedOrderMapper.selectByOrderGoods(orderId);
        orderDetailOrderVo.setGoodsOrderList(goodsOrderVoList);

        return orderDetailOrderVo;


    }
}
